package com.mystore.console.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mystore.common.paging.StylePage;
import com.mystore.framework.pojo.App;
import com.mystore.framework.service.impl.IAppServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.annotation.Resource;

@Controller
@RequestMapping("console/app")
public class AppCenterController {
    /**
     * 服务对象
     */
    @Resource
    private IAppServiceImpl iAppServiceImpl;

    @GetMapping("/search.do")
    public String search(Model model,String data, @RequestParam(defaultValue = "1") long current, @RequestParam(defaultValue = "4") long size) {
        StylePage<App> appPage = new StylePage<>(iAppServiceImpl.selectOnlinePageByData(data,new Page<>(current, size)));
        model.addAttribute("apps", appPage);
        model.addAttribute("data",data);
        return "search_result";
    }
    @GetMapping("/info.do")
    public String info(Model model,int appId) {
        App app= iAppServiceImpl.selectById(appId);
        model.addAttribute("app", app);
        return "console_app_info";
    }
}

